-NEW: blah blah
NEW: Add Cetus support. Thanx to Ron Parker and Kjeld Jensen.
+NEW: Add gpspilot support.
NEW: Windows support. You must download and install the expat dll if you
do not already have it. Get it from
http://sourceforge.net/projects/mingwrep/
+
+FIXED: Bad math in gpsutil.
FMTS=magproto.o gpx.o geo.o gpsman.o mapsend.o mapsource.o \
gpsutil.o tiger.o pcx.o csv.o cetus.o gpspilot.o magnav.o
-OBJS=main.o queue.o route.o waypt.o util.o vecs.o coldsync/util.o coldsync/pdb.o $(FMTS)
+OBJS=main.o queue.o route.o waypt.o util.o vecs.o mkshort.o \
+ coldsync/util.o coldsync/pdb.o $(FMTS)
all: gpsbabel
MAGELLAN
- Waypoint upload and download works reliably.
+ Waypoint serial upload and download works reliably to the 315, 330,
+ Meridian, and SportTrak family. I expect it to work on any modern
+ Magellan unit.
+
+ As of 08/30/02, gpsbabel can also read and write the files that
+ can be stuck on the flash memory parts
+
+BLAH BLAH BLAH
As of this writing, there is still a lot of "scribbling" in the
source for functionality that isn't hooked up to the rest of the
yet, a module that implements it. I spent time trying to reverse-
engineer a couple of *.mps files then I remembered that I don't own
a Garmin and wasn't that inspired.
+
+ CETUS
+
+ Cetus GPS (http://www.cetusgps.dk/) is a program for Palm/OS.
+ Working with Ron Parker and Kjeld Jensen, we can now read and write
+ files for that program. It hasn't been exhaustively tested, but
+ has seemed fine on every input and output we've tried.
+
+ GPSPILOT
+
+ The file format for GPSPILOT (http://www.gpspilot.com) was provided
+ by Ron Parker. GPSbabel can currently read gpspilot files, but not
+ write them.
COMMON USAGE
* data in this file.
*/
+typedef struct {
+ int synthesize_shortnames;
+} global_options;
+
+extern global_options global_opts;
+
/*
* A coordinate in space.
*/
void waypt_disp_all(waypt_cb);
unsigned int waypt_count(void);
void fprintdms(FILE *, coord *, int);
+char *mkshort (const char *);
+void setshort_length(int n);
+void setshort_badchars(const char *);
typedef struct ff_vecs {
ff_init rd_init;
lat = wpt->position.latitude.degrees * 100.0;
fprintf(file_out, "%-8s %08.3f%c %09.3f%c %07.0f%c %-30.30s %s\n",
- wpt->shortname,
+ global_opts.synthesize_shortnames ?
+ mkshort(wpt->description) : wpt->shortname,
fabs(lat),
lat < 0.0 ? 'S' : 'N',
fabs(lon),
lat, ilon < 0 ? 'N' : 'S',
lon, ilat < 0 ? 'E' : 'W',
waypointp->position.altitude.altitude_meters,
- waypointp->shortname,
+ global_opts.synthesize_shortnames ?
+ mkshort(waypointp->description) : waypointp->shortname,
waypointp->description ? waypointp->description : "",
icon_token);
mag_writemsg(obuf);
#include "defs.h"
+global_options global_opts;
+
void
usage(const char *pname)
{
- printf("Usage: %s -i <INPUT_FILE_TYPE> -f <INPUT_FILE> -o <OUT FTYPE> -F <OUTPUT_FILE>\n", pname);
+ printf("Usage: %s [-s] -i <INPUT_FILE_TYPE> -f <INPUT_FILE> -o <OUT FTYPE> -F <OUTPUT_FILE>\n", pname);
printf("Supported file types:\n");
disp_vecs();
}
c = argv[argn][1];
optarg = argv[argn+1];
- argn++;
switch (c) {
case 'i':
ivecs = find_vec(optarg);
+ argn++;
break;
case 'o':
ovecs = find_vec(optarg);
+ argn++;
break;
case 'f':
fname = optarg;
+ argn++;
if (ivecs == NULL) {
fatal ("No valid input type specified");
}
break;
case 'F':
ofname = optarg;
+ argn++;
if (ovecs) {
ovecs->wr_init(ofname);
ovecs->write();
}
break;
+ case 's':
+ global_opts.synthesize_shortnames = 1;
+ break;
case 'h':
case '?':
usage(argv[0]);
#include <string.h>
-const char badchars[] = "\"$.,'!-";
-const char vowels[] = "aeiouAEIOU";
+static const char vowels[] = "aeiouAEIOU";
-#define TGT_LEN 8
+#define DEFAULT_TARGET_LEN 8
+static int target_len = DEFAULT_TARGET_LEN;
+
+#define DEFAULT_BADCHARS "\"$.,'!-"
+static const char *badchars = DEFAULT_BADCHARS;
+
+static int mustupper = 0;
/*
* This is the stuff that makes me ashamed to be a C programmer...
*/
+static
char *
delete_last_vowel(int start, char *istring, int *replaced)
{
}
+/*
+ * Externally callable function to set the max length of the
+ * strings returned by mkshort(). 0 resets to default.
+ */
+void
+setshort_length(int l)
+{
+ if (l == 0) {
+ target_len = DEFAULT_TARGET_LEN;
+ } else {
+ target_len = l;
+ }
+}
+
+/*
+ * Externally callable function to set the string of characters
+ * that must never appear in a string returned by mkshort. NULL
+ * resets to default.
+ */
+void
+setshort_badchars(const char *s)
+{
+ if (s == NULL) {
+ badchars = DEFAULT_BADCHARS;
+ } else {
+ badchars = strdup(s);
+ }
+}
+
+void
+setshort_mustupper(int i)
+{
+ mustupper = i;
+}
+
char *
mkshort(char *istring)
{
cp = ostring;
for (i=0;i<l;i++) {
if (!isspace(tstring[i])) {
+ if (mustupper) {
+ tstring[i] = toupper(tstring[i]);
+ }
*cp++ = tstring[i];
}
}
* them. If we run out of string, give up.
*/
replaced = 1;
- while (replaced && strlen(ostring) > TGT_LEN) {
+ while (replaced && strlen(ostring) > target_len) {
ostring = delete_last_vowel(2, ostring, &replaced);
}
* Now brutally truncate the resulting string, preserve trailing
* numeric data.
*/
- if ((i = strlen(ostring)) > TGT_LEN) {
- strcpy(&ostring[TGT_LEN] - strlen(np), np);
+ if ((i = strlen(ostring)) > target_len) {
+ strcpy(&ostring[target_len] - strlen(np), np);
}
return ostring;
}
-
+#if 0
char *foo[] = {
"VwthPst# 3700.706N 08627.588W 0000000m View the Past #2 ",
"PilotRoc 3655.270N 08717.173W 0000000m Pilot Rock by CacheAdvance ",
printf("%s\n", delete_last_vowel(0, "aexxx", &r));
}
+#endif
}
fprintf(file_out, "W %-6.6s %c%08.5f %c%011.5f %s %5d %-40.40s %5e %s\n",
- wpt->shortname,
+ global_opts.synthesize_shortnames ?
+ mkshort(wpt->description) : wpt->shortname,
lat < 0.0 ? 'S' : 'N',
fabs(lat),
lon < 0.0 ? 'W' : 'E',
"U LAT LON DM\n"
"\n"
"H IDNT LATITUDE LONGITUDE DATE TIME ALT DESCRIPTION PROXIMITY SYMBOL ;waypts\n");
-
+ setshort_length(6);
waypt_disp_all(gpsutil_disp);
}
printposn(&wpt->position.latitude,1);
printposn(&wpt->position.longitude,0);
printf("%s/%s %f\n",
- wpt->shortname,
+ global_opts.synthesize_shortnames ?
+ mkshort(wpt->description) : wpt->shortname,
wpt->description,
wpt->position.altitude.altitude_meters);
}
{
queue *elem, *tmp;
waypoint *waypointp;
-
+setshort_length(8);
+setshort_mustupper(0);
QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
waypointp = (waypoint *) elem;
(*cb) (waypointp);